-
Notifications
You must be signed in to change notification settings - Fork 41.3k
Migrate to Spring Batch 6 #46216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Migrate to Spring Batch 6 #46216
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. There are a number of things we need to fix before going forward. I've added comments.
@@ -172,6 +172,7 @@ protected ExecutionContextSerializer getExecutionContextSerializer() { | |||
: super.getExecutionContextSerializer(); | |||
} | |||
|
|||
@SuppressWarnings("removal") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what to make of this. The method is deprecated but the class isn't. If we don't want this to be configurable going forward, I'd rather remove the override (and the ObjectProvider
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could still be configurable until the method is removed in Spring Batch 6.2. Maybe this configuration option should be documented as deprecated in Spring Boot docs? Wdyt?
import org.springframework.core.convert.support.ConfigurableConversionService; | ||
|
||
/** | ||
* Callback interface that can be implemented by beans wishing to customize the | ||
* {@link ConfigurableConversionService} that is | ||
* {@link DefaultBatchConfiguration#getConversionService provided by | ||
* {@link JdbcDefaultBatchConfiguration#getConversionService provided by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should relax the javadoc a bit. It looks weird that we refer to that method. Something like
Callback interface that can be implemented by beans wishing to customize the ConfigurableConversionService that is use by the batch infrastructure while retaining its default auto-configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
private JobParameters getNextJobParameters(Job job, JobParameters jobParameters) { | ||
if (this.jobRepository != null && this.jobRepository.isJobInstanceExists(job.getName(), jobParameters)) { | ||
if (this.jobRepository != null && this.jobRepository.getJobInstance(job.getName(), jobParameters) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something should be adapted in Spring Batch here. JobRepository
isn't deprecated but JobExplorer
is. The former extends the latter so any method that is not specified in the child is flagged as deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spring Batch was updated. I have removed the @SuppressWarning("removed")
.getNextJobParameters(job) | ||
.toJobParameters(); | ||
return merge(nextParameters, jobParameters); | ||
} | ||
|
||
@SuppressWarnings("deprecated") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I see what this suppresses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was meant to suppress the warning about the call of the deprecated method jobRepository.getLastJobExecution
. But this is now fixed.
@@ -114,6 +107,7 @@ | |||
* @author Yanming Zhou | |||
*/ | |||
@ExtendWith(OutputCaptureExtension.class) | |||
@SuppressWarnings("removal") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the plan to deal with those deprecations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in Spring Batch.
// the following assertion should pass as taskExecutor is inherited from | ||
// TaskExecutorJobLauncher | ||
// assertThat(context.getBean(JobOperator.class)).hasFieldOrPropertyWithValue("taskExecutor", | ||
// batchTaskExecutor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't comment code like that.
The assertion does not pass because context.getBean(JobOperator.class)
returns a JDK Proxy. And that proxy does not have such field. We should figure out why it returns a proxy and it didn't before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the assertion.
...est/java/org/springframework/boot/autoconfigure/batch/JobLauncherApplicationRunnerTests.java
Show resolved
Hide resolved
There a number of things that should happen in Spring Batch before we can make progress here, notably a status on |
- Fix deprecation warnings - Fix assertion in BatchAutoConfigurationTests - Update Javadocs
Thanks for the review.
The deprecation was reverted.
This was fixed in Spring Batch. I will add some inline comments as well. |
This PR upgrades Spring Boot 4 to Spring Batch 6.
Most of the changes are documented here: https://github.com/spring-projects/spring-batch/wiki/Spring-Batch-6.0-Migration-Guide